from flask_restful import Api

from main.apis.admin.admin_api import AdminRegisterResource, AdminLoginResource
from main.apis.user.cart_api import CartResource
from main.apis.user.order_api import OrderResource
from main.apis.user.pay_api import PayResource, PaidResource
from main.apis.user.user_api import BuyResource, UsersResource
from main.apis.goods.goods_api import GoodsList, GoodObj

api = Api()


def init_api(app):
    api.init_app(app)


# 也可以将api注册放到每个api当中
api.add_resource(GoodsList, '/goods/')
api.add_resource(GoodObj, '/good/<int:id>/')
api.add_resource(AdminRegisterResource, '/admin/register/')
api.add_resource(AdminLoginResource, '/admin/login/')
api.add_resource(BuyResource, '/buy/<int:id>/<int:count>')
api.add_resource(UsersResource, '/user/')
api.add_resource(CartResource, '/cart/')
api.add_resource(OrderResource, '/order/')
api.add_resource(PayResource, '/pay/<int:order_id>')
api.add_resource(PaidResource, '/paid/')
